/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package koncowka;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author root
 */
public class BlokadaKlienta {

    private String apMAC;
    private String klientMAC;
    private Process proc;

    public BlokadaKlienta(String apMAC, String klientMAC) {
        this.apMAC = apMAC;
        this.klientMAC = klientMAC;
        start();
    }
    
    
    
    public void start() {
        
        
        //String[] skrypt = {"bash", "/root/NetBeansProjects/Grupowy/trunk/Koncowka/src/skrypty/blokada.sh "+apMAC+" "+klientMAC};
        String tmp = "aireplay-ng -0 0 -a " + apMAC + " -c " + klientMAC + " wlan0";
        String[] skrypt = new String[2];
        skrypt[0]= "bash";
        skrypt[1]= tmp;
        try {
            ProcessBuilder pb = new ProcessBuilder("aireplay-ng","-0","0","-a",apMAC,"-c",klientMAC,"wlan0");
            pb.redirectError(new File("bledy.txt"));
            pb.redirectOutput(new File("out.txt"));
            proc = pb.start();
            //proc = Runtime.getRuntime().exec(skrypt);
            System.out.println("zalaczylem blokowanie");
        } catch (IOException ex) {
            Logger.getLogger(BlokadaKlienta.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public void stop(){
        proc.destroy();
    }
    
    
    
}
